package com.github.dengmin.mysql.mapper;

import com.github.dengmin.mysql.model.User;
import org.springframework.jdbc.core.RowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;

/**
 * @Author dengmin
 * @Created 2020/7/1 下午3:42
 */
public class UserRowMapper implements RowMapper<User> {
    private static final long serialVersionUID = 1L;

    @Override
    public User mapRow(ResultSet resultSet, int i) throws SQLException {
        User user = new User();
        user.setId(resultSet.getLong("id"));
        user.setUsername(resultSet.getString("username"));
        user.setNickname(resultSet.getString("nickname"));
        user.setPassword(resultSet.getString("password"));
        user.setSalt(resultSet.getString("salt"));
        user.setEnable(resultSet.getBoolean("enable"));
        user.setRoleId(resultSet.getLong("roleId"));
        user.setGender(resultSet.getInt("gender"));
        user.setGmtCreated(resultSet.getTimestamp("gmtCreated"));
        user.setGmtModify(resultSet.getTimestamp("gmtModify"));
        return user;
    }
}
